package o;

import android.content.Intent;
import android.content.IntentFilter;
import android.database.sqlite.SQLiteException;
import android.os.AsyncTask;
import com.huawei.appmarket.service.selfupdate.ClientInstallReceiver;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class dsi extends AsyncTask<Void, Void, Void> {
    private static final Executor ˋ = Executors.newFixedThreadPool(1);
    private static String ˎ = "ApkObtainTask";
    private Object ˊ = null;
    private b ˏ = b.Undefined;
    private boolean ॱ = false;
    private AsyncTask ॱॱ;

    public enum b {
        Undefined,
        InstalledApkDetect,
        UnInstalledApkDetect,
        DownloadFileDectect,
        UpdatableApkDetectFromCache,
        OnlineDataDetect,
        InstallExecptionRecovery
    }

    protected /* synthetic */ Object doInBackground(Object[] objArr) {
        return ˏ((Void[]) objArr);
    }

    protected /* synthetic */ void onPostExecute(Object obj) {
        ˊ((Void) obj);
    }

    public static void ˋ(b bVar, Object obj, boolean z) {
        dsi o_dsi = new dsi();
        o_dsi.ˏ = bVar;
        o_dsi.ˊ = obj;
        o_dsi.ॱ = z;
        o_dsi.executeOnExecutor(dso.ˊ, new Void[0]);
    }

    public static void ˏ(AsyncTask asyncTask) {
        if (asyncTask == null) {
            Logger.e(ˎ, "runTask can not be null.");
            return;
        }
        dsi o_dsi = new dsi();
        o_dsi.ˏ = b.OnlineDataDetect;
        o_dsi.ॱॱ = asyncTask;
        o_dsi.executeOnExecutor(dso.ˊ, new Void[0]);
    }

    protected Void ˏ(Void... voidArr) {
        euc.ˊ().ॱ();
        ॱ();
        euc.ˊ().ˏ();
        return null;
    }

    protected void ˊ(Void voidR) {
        super.onPostExecute(voidR);
        if (this.ॱॱ != null && this.ˏ == b.OnlineDataDetect) {
            this.ॱॱ.executeOnExecutor(ˋ, new Object[0]);
        }
        if (this.ॱ) {
            Intent intent = new Intent();
            intent.setAction(dvq.ˊ());
            intent.setPackage(ContentManager.getInstant().getContext().getPackageName());
            ContentManager.getInstant().getContext().sendBroadcast(intent);
        }
    }

    private void ॱ() {
        Logger.ˎ(ˎ, "Do task with cmd:" + this.ˏ + ",needNotify:" + this.ॱ + ",param:" + this.ˊ);
        if (this.ˏ == b.InstallExecptionRecovery) {
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction("PackageManager.action.CLIENT_SELF_INSTALL_EXECPTION");
            intentFilter.addAction("PackageManager.action.CLIENT_SELF_INSTALL");
            intentFilter.addAction("PackageManager.action.PACKAGE_MSG_DISPATCH");
            ll.ˏ(ContentManager.getInstant().getContext()).ˏ(new ClientInstallReceiver(), intentFilter);
            try {
                new dst().ॱ();
            } catch (SQLiteException e) {
                Logger.ˎ(ˎ, "catch SQLiteException when recoveryTask");
            } catch (Exception e2) {
                Logger.ˎ(ˎ, "catch SQLiteException when recoveryTask");
            }
        }
    }
}
